﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PRO.Common;
using PRO.Entity;
using System.Data;
using PRO.DbProvider;
using PRO.ORM;

namespace PRO.Product
{
    public class OrderLib
    {
        /// <summary>
        /// 创建订单
        /// </summary>
        /// <param name="order"></param>
        /// <param name="products"></param>
        /// <returns>返回订单id</returns>
        public static int CreateOrder(OrderInfo order,DataTable products)
        {
            return DataBaseProvider.GetInstance().CreateOrder(order, products);
        }
        /// <summary>
        /// 获取订单信息
        /// </summary>
        /// <param name="id"></param>
        /// <param name="userid"></param>
        /// <returns></returns>
        public static OrderInfo GetOrderInfo(int id, int userid)
        {
            OrderInfo info = new OrderInfo();
            info.BindDataToEntity(DataBaseProvider.GetInstance().GetOrderInfo(id, userid));
            return info;
        }
        /// <summary>
        /// 获取订单下的产品列表
        /// </summary>
        /// <param name="orderid"></param>
        /// <returns></returns>
        public static List<OrderItemInfo> GetOrderItems(int orderid)
        {
            List<OrderItemInfo> items = new List<OrderItemInfo>();
            items.BindDataToEntity(DataBaseProvider.GetInstance().GetOrderItems(orderid));
            return items;
        }
    }
}
